text: Update placeholder visibility more often
authorMatthias Clasen <mclasen@redhat.com>
Sun, 4 Jul 2021 02:15:38 +0000 (22:15 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 4 Jul 2021 02:15:38 +0000 (22:15 -0400)
We need to update the visibility of the placeholder
label when we create it, otherwise we can end up
with placeholder text on top of entry content.

Fixes: #4066
gtk/gtktext.c

index 2416e980f9242267c3d011b824bd8efc94b8001b..f3c23c3365dc06854349149b3755bc1bfbdbc78a 100644 (file)
@@ -3580,7 +3580,8 @@ update_placeholder_visibility (GtkText *self)
   if (priv->placeholder)
     gtk_widget_set_child_visible (priv->placeholder,
                                   priv->preedit_length == 0 &&
-                                  gtk_entry_buffer_get_length (priv->buffer) == 0);
+                                  (priv->buffer == NULL ||
+                                   gtk_entry_buffer_get_length (priv->buffer) == 0));
 }
 
 /* GtkEntryBuffer signal handlers
@@ -6652,6 +6653,8 @@ gtk_text_set_placeholder_text (GtkText    *self,
       gtk_label_set_text (GTK_LABEL (priv->placeholder), text);
     }
 
+  update_placeholder_visibility (self);
+
   g_object_notify_by_pspec (G_OBJECT (self), text_props[PROP_PLACEHOLDER_TEXT]);
 }